/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Interfaces;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.ListProperty;
import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.InternalStructures.Connector;
import edu.pku.sei.modeler.model.uml.Kernel.Property;
import edu.pku.sei.modeler.model.uml.Kernel.Operation;
import edu.pku.sei.modeler.model.uml.Kernel.Classifier;
import edu.pku.sei.modeler.model.uml.Communications.Reception;
import edu.pku.sei.modeler.model.uml.ProtocalStateMachines.ProtocalStateMachine;

import edu.pku.sei.modeler.model.uml.Kernel.Classifier;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Interface extends Classifier implements IInterface {
	// attributes
	
	
	
	
	// references
	
	protected MetaTypedList ownedAttribute;
	
	protected MetaTypedList ownedOperation;
	
	protected MetaTypedList nestedClassifier;
	
	protected MetaTypedList redefinedInterface;
	
	protected MetaTypedList ownedReception;
	
	protected MetaTypedList protocol;
	
//	especially for the storation of delegation
	protected MetaTypedList incoming;
	protected MetaTypedList outgoing;
	
	private int type;
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}

	public static final int TYPE_INTERFACE = 0;
	public static final int TYPE_USEINTERFACE = 1;
	public static final int TYPE_IMPLEMENTINTERFACE = 2;
	public static final int TYPE_COMPONENTINTERFACE = 3;
	
	// getters & setters for attributes
	
	// getters for references
	@MethodProperty(
			id = "INTERFACE_OWNEDATTRIBUTE",
			catalog = "Other",
			name = ModelPackage.INTERFACE_OWNEDATTRIBUTE
			)
	@ListProperty(
			allowTypes = {Property.class},
			newInstanceMethod = "newInstance",
			typeString = ModelPackage.__PROPERTY__
			)
	public MetaTypedList getOwnedAttribute() {
		if(ownedAttribute == null) {
			ownedAttribute = new MetaTypedList(Property.class, this, ModelPackage.INTERFACE_OWNEDATTRIBUTE);
		}
		return ownedAttribute;
	}
	@MethodProperty(
			id = "INTERFACE_OWNEDOPERATION",
			catalog = "Other",
			name = ModelPackage.INTERFACE_OWNEDOPERATION
			)
	@ListProperty(
			allowTypes = {Operation.class},
			newInstanceMethod = "newInstance",
			typeString = ModelPackage.__OPERATION__
			)
	public MetaTypedList getOwnedOperation() {
		if(ownedOperation == null) {
			ownedOperation = new MetaTypedList(Operation.class, this, ModelPackage.INTERFACE_OWNEDOPERATION);
		}
		return ownedOperation;
	}
	
	public MetaTypedList getNestedClassifier() {
		if(nestedClassifier == null) {
			nestedClassifier = new MetaTypedList(Classifier.class, this, ModelPackage.INTERFACE_NESTEDCLASSIFIER);
		}
		return nestedClassifier;
	}
	
	public MetaTypedList getRedefinedInterface() {
		if(redefinedInterface == null) {
			redefinedInterface = new MetaTypedList(Interface.class, this, ModelPackage.INTERFACE_REDEFINEDINTERFACE);
		}
		return redefinedInterface;
	}
	
	public MetaTypedList getOwnedReception() {
		if(ownedReception == null) {
			ownedReception = new MetaTypedList(Reception.class, this, ModelPackage.INTERFACE_OWNEDRECEPTION);
		}
		return ownedReception;
	}
	
	public MetaTypedList getProtocol() {
		if(protocol == null) {
			protocol = new MetaTypedList(ProtocalStateMachine.class, this, ModelPackage.INTERFACE_PROTOCOL);
		}
		return protocol;
	}
	
	public MetaTypedList getOutgoing() {
		if(outgoing == null) {
			outgoing = new MetaTypedList(Connector.class, this, ModelPackage.VERTEX_OUTGOING);
		}
		return outgoing;
	}
	
	public MetaTypedList getIncoming() {
		if(incoming == null) {
			incoming = new MetaTypedList(Connector.class, this, ModelPackage.VERTEX_INCOMING);
		}
		return incoming;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		// references
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.INTERFACE_OWNEDATTRIBUTE, ownedAttribute);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.INTERFACE_OWNEDOPERATION, ownedOperation);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.INTERFACE_NESTEDCLASSIFIER, nestedClassifier);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.INTERFACE_REDEFINEDINTERFACE, redefinedInterface);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.INTERFACE_OWNEDRECEPTION, ownedReception);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.INTERFACE_PROTOCOL, protocol);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.VERTEX_OUTGOING, outgoing);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.VERTEX_INCOMING, incoming);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		// references
		
		this.getOwnedAttribute().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.INTERFACE_OWNEDATTRIBUTE));
		
		this.getOwnedOperation().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.INTERFACE_OWNEDOPERATION));
		
		this.getNestedClassifier().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.INTERFACE_NESTEDCLASSIFIER));
		
		this.getRedefinedInterface().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.INTERFACE_REDEFINEDINTERFACE, this));
		
		this.getOwnedReception().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.INTERFACE_OWNEDRECEPTION));
		
		this.getProtocol().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.INTERFACE_PROTOCOL));

		this.getOutgoing().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.VERTEX_OUTGOING));
		
		this.getIncoming().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.VERTEX_INCOMING, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.INTERFACE_REDEFINEDINTERFACE.equals(featureID)) {
			getRedefinedInterface().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 